/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.model;

import buslog.Calendar;
import buslog.Event;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author degrave
 */
public class CalendarTableModel implements TableModel{
    
    private Set<TableModelListener> listeners;
    LinkedList<Event> event_list;

    public CalendarTableModel(LinkedList<Event> event_list){
        this.listeners = new HashSet<>();
        this.event_list = event_list;
    }
    
    @Override
    public int getRowCount() {
        return event_list.size();
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public String getColumnName(int columnIndex) {
        switch(columnIndex){
            case 0:
                return "Name";
            case 1:
                return "Date";
            case 2:
                return "Time";
            case 3:
                return "Text";
        }
        return "";
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch(columnIndex){
            case 0:
                return String.class;
            case 1:
                return String.class;
            case 2:
                return String.class;
            case 3:
                return String.class;
        }
        return null;
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Calendar cal;
        
        cal.eventList = event_list.get(rowIndex);
            switch (columnIndex) {
            case 0:
                return prod.getId();
            case 1:
                return prod.getStart_time();
            case 2:
                return prod.getEnd_time();
            case 3:
            }
            return "";
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
        listeners.add(l);
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
        listeners.remove(l);
    }
}
